package 适配器模式.快排和二分查找;

//适配器类
public class DataOperationImpl implements DataOperation {

    private QuickSort quickSort;//聚合快排类
    private BinarySearch binarySearch;//聚合二分查找类

    //构造方法
    public DataOperationImpl(QuickSort quickSort, BinarySearch binarySearch) {
        this.quickSort = quickSort;
        this.binarySearch = binarySearch;
    }

    //排序
    public int[] sort(int[] arr) {
        return quickSort.quickSory(arr);
    }

    //查找
    public int search(int[] arr, int target) {
        return binarySearch.binarySearch(arr, target);
    }
}
